import React from 'react';
import Taro from '@tarojs/taro';

import * as T from '../types';
import actions from '../actions/index';
import { connect } from 'react-redux';
import { store2Props } from '../selectors';
type IInfoProps = T.IProps & T.IInfoProps;

import { Text, View, Image, ScrollView, Input } from '@tarojs/components';
import './Selecteds.less';
import FormSelect from '@/pages/common/form-select';
import "taro-ui/dist/style/components/action-sheet.scss";

// @ts-ignore
@connect<Partial<IInfoProps>, T.IInfoState>(store2Props, actions)
export default class Selecteds extends React.Component<Partial<IInfoProps>, T.IInfoState> {

  render() {
    let {
      main: { communityId, communityName, courierStationId, courierStationName, selectedTime, addressSelect },
      actions: { action },
    } = this.props;

    return (
      <>
        <View className="componentSelecteds">
          <>
            <View className="info2">
              <View className="top-select-add">
                <FormSelect
                  labelName="小区名称"
                  value={communityId ? communityName : void 0}
                  formStyle={{
                    paddingLeft: 0,
                    paddingRight: 0,
                  }}
                  placeholder="请选择小区"
                  selectRight={{ flex: 1, justifyContent: 'space-between' }}
                  inputStyle={{
                    fontSize: '14px',
                    color: 'rgba(0,0,0,0.8)',
                    textAlign: 'right',
                    flex: '1',
                  }}
                  onClick={() => {
                    action.commonChange('main.showCommunity', true)
                  }}
                />
              </View>
            </View>
          </>
          <>
            <View className="info2">
              <View className="top-select-add">
                <FormSelect
                  labelName="快递站点"
                  value={courierStationId ? courierStationName : void 0}
                  formStyle={{
                    paddingLeft: 0,
                    paddingRight: 0,
                  }}
                  placeholder="请选择站点"
                  selectRight={{ flex: 1, justifyContent: 'space-between' }}
                  inputStyle={{
                    fontSize: '14px',
                    color: 'rgba(0,0,0,0.8)',
                    textAlign: 'right',
                    flex: '1',
                  }}
                  onClick={() => {
                    if (!communityId) {
                      Taro.showToast({
                        title: '请先选择小区名称',
                        icon: 'none',
                        duration: 2000
                      })
                      return
                    }
                    action.commonChange('main.showCourierStation', true)
                  }}
                />
              </View>
            </View>
          </>
          <>
            <View className="info2">
              <View className="top-select-add">
                <FormSelect
                  labelName="送达时间"
                  value={!!selectedTime ? '今天 ' + selectedTime : void 0}
                  underline
                  formStyle={{
                    paddingLeft: 0,
                    paddingRight: 0,
                  }}
                  placeholder="请选择时间"
                  selectRight={{ flex: 1, justifyContent: 'space-between' }}
                  inputStyle={{
                    fontSize: '14px',
                    color: 'rgba(0,0,0,0.8)',
                    textAlign: 'right',
                    flex: '1',
                  }}
                  onClick={() => {
                    action.commonChange('main.showDeliveryTime', true)
                  }}
                />
              </View>
            </View>
          </>
          <>
            <View className="info2">
              <View className="top-select-add">
                <FormSelect
                  labelName="送达地址"
                  underline
                  value={addressSelect ? addressSelect.addressInfo : void 0}
                  formStyle={{
                    paddingLeft: 0,
                    paddingRight: 0,
                  }}
                  placeholder="请选择地址"
                  selectRight={{ flex: 1, justifyContent: 'space-between' }}
                  inputStyle={{
                    fontSize: '14px',
                    color: 'rgba(0,0,0,0.8)',
                    textAlign: 'right',
                    flex: '1',
                  }}
                  onClick={() => {
                    Taro.navigateTo({
                      url: '/pages/package-D/addressSelect/index',
                    });
                  }}
                />
              </View>
            </View>
          </>
        </View>
      </>
    );
  }
}
